<?php
/************************
* Simple News Engine 0.2.3
* author: Ragnaar <ragnaar@km.ru>
* home: http://code.google.com/p/sne-news
* date: 08.06.2011
*********************/
define('_VALID_SNE', '1');
define('SNE_PATH', dirname(__FILE__));

require_once SNE_PATH."/config.php";
require_once SNE_PATH."/lng/".$language.".php";
require_once SNE_PATH."/connect.php";
require_once SNE_PATH."/functions.php";

    $num = (int)$_POST['num'];
    $date = _filter($_POST['date'], 1);
    $socnet = _filter($_POST['socnet'], 1);
    $id = (int)$_POST['id'];

if ($socnet == "vk"){
    
    $query = prefix("UPDATE `{prefix}comments` SET `num` = '".$num."', `date` = '".$date."', `socnet` = '".$socnet."' WHERE `nid` = '".$id."'", $dbprefix);
    mysql_query($query) or die (mysql_error());
	if (mysql_affected_rows() <= 0) {
		$query = prefix("INSERT INTO `{prefix}comments` (`num`, `date`, `socnet`, `nid`) VALUES ('$num','$date', '$socnet', '$id')", $dbprefix);
	    mysql_query($query) or die (mysql_error());
	}
	$query = prefix("UPDATE `{prefix}news` SET `comment` = '1' WHERE `id` = '".$id."'", $dbprefix);
	mysql_query($query) or die (mysql_error());
    if ($num > 0){
        echo "<span class='nicons ncomm'><a href='".$newsPath."?mode=news&amp;id=".$id."#comments'>".$num._SNE_COMMENTS."</a></span>\n";
    } 
}

if ($_POST['socnet'] == "fb"){}

?>